package Test;

import javax.swing.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class Mouse extends JFrame implements MouseListener {
    JButton jbt1 = new JButton("点我啊");
    public Mouse() {
        //设置界面宽高
        this.setSize(603, 680);
        //设置界面标题
        this.setTitle("拼图游戏单机版v1.0");
        //设置界面置顶(点击其他界面还在最上层)
        this.setAlwaysOnTop(true);
        //设置界面居中
        this.setLocationRelativeTo(null);
        //设置关闭模式(点×结束程序运行)
        this.setDefaultCloseOperation(3);//3为关一个界面程序停止(WindowConstants.EXIT_ON_CLOSE)2为关闭所有界面才停止
        //取消默认的居中放置，取消了才能实现图片的x y 轴放置
        this.setLayout(null);

        jbt1.setBounds(0,0,150,50);
        jbt1.addMouseListener(this);

        this.getContentPane().add(jbt1);

        this.setLayout(null);

        this.setVisible(true);
    }
    @Override
    public void mouseClicked(MouseEvent e) {
        System.out.println("单击");
    }

    @Override
    public void mousePressed(MouseEvent e) {
        System.out.println("按下不松");

    }

    @Override
    public void mouseReleased(MouseEvent e) {
        System.out.println("松开");

    }

    @Override
    public void mouseEntered(MouseEvent e) {
        System.out.println("划入");
    }

    @Override
    public void mouseExited(MouseEvent e) {
        System.out.println("划出");
    }
}
